package com.tz.init;

import com.tz.AppConfig;
import com.tz.dao.CategoryDao;
import com.tz.dao.PictureDao;
import com.tz.dao.ProductDao;
import com.tz.entity.Category;
import com.tz.entity.Faq;
import com.tz.entity.Product;
import com.tz.service.CategoryService;
import com.tz.service.FaqService;
import com.tz.service.PictureService;
import com.tz.service.ProductService;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Created by Administrator on 16-7-28.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = AppConfig.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class InitData {

    @Autowired
    private CategoryService categoryService;
    @Autowired
    private ProductService productService;
    @Autowired
    private PictureService pictureService;
    @Autowired
    private FaqService faqService;

    @Test
    public void initCategory() {
        Category category1 = new Category("ELECTRONICS",null,null);
        categoryService.saveCategorys(category1);

    }
    @Test
    public void initProducts() {
        Product p1 = new Product("相机1","hhhhh",110,100,10,"dddddd",null,130,"xxxx","red",null);
        Product p2 = new Product("相机2","hhhhh",120,100,10,"dddddd",null,130,"xxxx","red",null);
        Product p3 = new Product("相机3","hhhhh",130,100,10,"dddddd",null,130,"xxxx","red",null);
        Product p4 = new Product("相机4","hhhhh",140,100,10,"dddddd",null,130,"xxxx","red",null);
        Product p5 = new Product("相机5","hhhhh",150,100,10,"dddddd",null,130,"xxxx","red",null);
        Product p6 = new Product("相机6","hhhhh",160,100,10,"dddddd",null,130,"xxxx","red",null);
        productService.saveProducts(p1);
        productService.saveProducts(p2);
        productService.saveProducts(p3);
        productService.saveProducts(p4);
        productService.saveProducts(p5);
        productService.saveProducts(p6);
    }
    @Test
    public void initPicture() {
    }

    @Test
    public void initFaq() {

        Faq f1 = new Faq("女朋友和老妈同时掉到水了,你先救谁?","#￥#@￥#@#%#@￥@￥#@￥#%#@￥@￥#@￥","collapseOne");
        Faq f2 = new Faq("月亮太阳看起来为什么一样大","从地球上望月球，它看上去与太阳的大小差不多，造成这种错觉是距离奇怪的安排","collapseTwo");
        Faq f3 = new Faq("脱毛衣时为什么会冒火花","由于化纤衣物之间的摩擦产生了静电","collapseThree");
        Faq f4 = new Faq("太阳系中的八大行星","水星（☿）、金星（♀）、地球（⊕）、火星（♂）、木星（♃）、土星（♄）、天王星（♅）、海王星（♆）","collapseFour");
        Faq f5 = new Faq("TAEYANG","TAEYANG（东永裴、동영배），1988年5月18日出生于韩国京畿道议政府市，韩国男歌手，男子演唱组合Bigbang成员之一。","collapseFive");
        Faq f6 = new Faq("青山黛玛","日本女歌手","collapseSix");
        faqService.save(f1);
        faqService.save(f2);
        faqService.save(f3);
        faqService.save(f4);
        faqService.save(f5);
        faqService.save(f6);
    }

}
